// -----------------------------
// Author: 		Dhaenens Gert	
// Creation: 	1/5/2014 9:51:29 PM				
// -----------------------------

#include "CMath.h"

#include <math.h>

namespace Flow
{

	const Float	Math::Pi = 3.14159265f;
	const Float	Math::PiOver2 = 1.57079632f;
	const Float	Math::PiTimes2 = 6.28318530f;
	const Float	Math::PiOver4 = 0.78539816f;
	const Float	Math::PiTimes4 = 12.56637061f;
	const Float	Math::Epsilon = 0.00000001f;
	
	Float Math::Lerp(Float a, Float b, Float alpha)
	{
		return (a + ((b - a) * alpha));
	}
	Float Math::Sin(Float fAngle)
	{
		return sinf(fAngle);
	}
	Float Math::Cos(Float fAngle)
	{
		return cosf(fAngle);
	}
	Float Math::Tan(Float fAngle)
	{
		return tanf(fAngle);
	}
	Float Math::Sqrt(Float fValue)
	{
		return sqrtf(fValue);
	}
	Float Math::Deg2Rad(Float fDegrees)
	{
		return (fDegrees * (Math::Pi / 180.0f));
	}
	Float Math::Rad2Deg(Float fRadians)
	{
		return (fRadians * (180.0f / Math::Pi));
	}
	Float Math::Abs(Float fValue)
	{
		return fabsf(fValue);
	}
	Int32 Math::Abs(Int32 fValue)
	{
		return abs(fValue);
	}
	Float Math::Pow(Float a, Float exp)
	{
		return powf(a, exp);
	}
	Float Math::Pow(Float a, Int32 exp)
	{
		return pow(a, exp);
	}
	Float Math::Min(Float a, Float b)
	{
		return (a < b) ? a : b;
	}
	Float Math::Max(Float a, Float b)
	{
		return (a > b) ? a : b;
	}
	UInt32 Math::Min(UInt32 a, UInt32 b)
	{
		return (a < b) ? a : b;
	}
	UInt32 Math::Max(UInt32 a, UInt32 b)
	{
		return (a > b) ? a : b;
	}
	Int32 Math::Min(Int32 a, Int32 b)
	{
		return (a < b) ? a : b;
	}
	Int32 Math::Max(Int32 a, Int32 b)
	{
		return (a > b) ? a : b;
	}
	Float Math::Clamp(Float a, Float min, Float max)
	{
		return Math::Min(max, Math::Max(min, a));
	}
	Float Math::Floor(Float a)
	{
		return floor(a);
	}
	Float Math::Ceil(Float a)
	{
		return ceil(a);
	}
	Float Math::Mod(Float a, Float mod)
	{
		return fmodf(a, mod);
	}
	Float Math::WrapUniform(Float a)
	{
		Float val = Mod(a, 1.0f);
		if (val < 0.0f)
			return 1.0f - Math::Abs(val);
		return val;
	}

}